# -*- coding: utf-8 -*-
from auto.untils import SystemManager


def is_exists_jdk():
    """
    :return:  是否存在jdk
    """
    try:
        command = SystemManager()
        res = command.run_command("java -version")

        print(res)
        if res.returncode == 0 and "version" in res.stderr:
            if "1.8" in res.stderr:
                return True
    except Exception as e:
        raise e


def install_jdk():
    """
    安装jdk
    :return:
    """
    print(" 正在安装 java-1.8.0-openjdk-devel...")
    command = SystemManager()
    command.run_command("yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel")
